""" модуль взаимодействия и регистрации плагинов """

from httpx import AsyncHTTPTransport
from .base import BaseSourceProvider, BaseFilterProvider, BaseOutputProvider
from . import sources
from . import filters
from . import outputs


def unused():
    """Чтобы убрать предупреждение о неиспользуемых импортах"""
    return sources, filters, outputs


def use_plugins(config: dict, ipv4t: AsyncHTTPTransport, ipv6t: AsyncHTTPTransport):
    """Регистрация всех плагинов указаных в конфигурации"""
    for source_name in config.get("sources", []):
        BaseSourceProvider.register_provider(
            source_name, config["sources"][source_name], ipv4t, ipv6t
        )

    for filter_name in config.get("filters", []):
        BaseFilterProvider.register_provider(
            filter_name, config["filters"][filter_name], ipv4t, ipv6t
        )

    for output_name in config.get("outputs", []):
        BaseOutputProvider.register_provider(
            output_name, config["outputs"][output_name], ipv4t, ipv6t
        )
